package com.example.eureka.service.employee.web;

import com.example.eureka.service.employee.domain.Employee;
import com.example.eureka.service.employee.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/employee")
public class EmployeeController {

    @Autowired
    private EmployeeService employeeService;

    @GetMapping("/{id}")
    public Map<String, Object> getEmployee(@PathVariable("id") Long id) {
        Employee employee = employeeService.getEmployee(id);


        Map<String, Object> map = new HashMap<>();
        map.put("code", 10000);
        map.put("msg", "success");
        map.put("data", employee);

        return map;
    }

}

